package com.lzy.system.organization.util;

import com.lzy.system.organization.entity.security.entity.SecurityUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * description: 用户通用类 <br>
 * date: 2023/12/19 上午9:46 <br>
 * author: lcc <br>
 * version: 1.0 <br>
 */
@Component
public class UserCommon {
    /**
     * 获取当前用户的userId
     * @return
     */
    public String getCurrentUserId(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        SecurityUser securityUser = (SecurityUser)authentication.getPrincipal();
        return securityUser.getUsername();
    }
}
